<template>
    <el-dialog title="设备测点" :visible.sync="displayWin" width="80%" :lock-scroll="true" :close-on-click-modal="false">
        <div style="position: relative; top: -50px">
            <zy-table style="height: 550px" :tableData="tableData" :tableColumn="tableColumn"></zy-table>
        </div>
    </el-dialog>
</template>

<script>
import { mapState } from 'vuex'
import { column1 } from './formConfig.js'
import zyTable from '@/components/common/zyTable.vue'
import { getEigenvalueTagsApi, deviceGetSensorsApi } from '@/requset/api'
export default {
    components: { zyTable },
    data() {
        return {
            static_url: '/static',
            displayWin: false,
            tableData: [],
            tableColumn: column1,
            eigenvalues: [],
            deviceTypes: [],
            sensorTypes: [],
            directionTypes: {
                A: 'A轴向',
                H: 'H水平',
                V: 'V垂直',
            },
        }
    },
    created() {
        let dirc = {}
        this.eigenvalueTags.map((item) => {
            dirc[item.id] = item.name
        })
        this.eigenvalues = dirc
        dirc = {}
        this.sensorType.map((item) => {
            dirc[item.id] = item.name
        })
        this.sensorTypes = dirc
        this.tableColumn[this.tableColumn.length - 1].format = (val) => val.map((item) => this.eigenvalues[item]).join(',')
        this.tableColumn[3].format = (val) => this.directionTypes[val]
        this.tableColumn[5].format = (val) => this.sensorTypes[val]
    },
    methods: {
        doOpen(id) {
            this.displayWin = true
            if (!id || id.length <= 0) return
            deviceGetSensorsApi(id).then((res) => {
                if (res.data.code != 0) return
                this.tableData = res.data.data.map((item) => {
                    if (item.eigenvalue) {
                        item.eigenvalue = item.eigenvalue.split(',')
                    }
                    return item
                })
            })
        },
    },
    computed: {
        ...mapState('backstage', ['backstageData', 'eigenvalueTags', 'sensorType']),
    },
}
</script>

<style scoped lang="less"></style>
